package com.kaibes.web.status;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.core.io.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import com.kaibes.core.base.util.FileUtils;
import com.kaibes.web.util.ResourceUtils;

@Controller
public class StatusController {
    
    @GetMapping("/error/{status}")
    public void error(HttpServletResponse response, @PathVariable int status) {
        Resource resource = ResourceUtils.findResource("error/"+status+".html");
        if (resource!=null) {
        	try {
				FileUtils.transferTo(resource.getFile(), response.getOutputStream());
			} catch (IOException e) {
				e.printStackTrace();
			}
        }
        
    }
}
